from django.conf.urls.defaults import *
from django.http import HttpResponseRedirect
import settings

def redirect(url):
    def inner(request):
        return HttpResponseRedirect(url)
    return inner

urlpatterns = patterns('',
    # Example:
    (r'^$', redirect('/cwd/products/')),
    (r'^gridpoints/', include('cwd.gridpoints.urls')),
    (r'^products/', include('cwd.products.urls')),

    # Uncomment this for admin:
#     (r'^admin/', include('django.contrib.admin.urls')),
)

if settings.DEBUG:
    import os
    urlpatterns += patterns('',
        #(r'^cwd/media/(.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
        (r'^cwd/media/(.*)$', 'django.views.static.serve', {'document_root':os.path.join(os.path.dirname(__file__), 'media'), }),
        (r'^cwd/testing/', include('cwd.testing.urls')),
        (r'^cwd/products/', include('cwd.products.urls')),
    )
